﻿using System.Windows;
using System.Windows.Media;

namespace OurMind.Controls.Connectors
{
    ///<summary>连接符的箭头方向。</summary>
    public enum ConnectorDirectionEnum
    {
        LeftBottomToRightTop,
        LeftTopToRightBottom,
    }

    ///<summary>连接符的基础控件类。</summary>
    public abstract class BaseConnector : FrameworkElement
    {
        ///<summary>
        /// 为了保证线的部分端点不会被剪裁掉，这里需要预留 Line Margin 来提供更多的画布空间。
        ///</summary>
        public const double LineMargin = 10;

        ///<summary>线的样式。</summary>
        public Pen LineBrush { get { return (Pen)GetValue(LineBrushProperty); } set { SetValue(LineBrushProperty, value); } }
        ///<summary>线的样式。</summary>
        public static readonly DependencyProperty LineBrushProperty = DependencyProperty.Register("LineBrush", typeof(Pen), typeof(BaseConnector), new FrameworkPropertyMetadata(CreateDefaultLineBrush())
        {
            AffectsRender = true,
        });

        ///<summary>方向。</summary>
        public ConnectorDirectionEnum Direction { get { return (ConnectorDirectionEnum)GetValue(DirectionProperty); } set { SetValue(DirectionProperty, value); } }
        public static readonly DependencyProperty DirectionProperty = DependencyProperty.Register("Direction", typeof(ConnectorDirectionEnum), typeof(BaseConnector), new FrameworkPropertyMetadata(ConnectorDirectionEnum.LeftBottomToRightTop)
        {
            AffectsRender = true,
        });

        private static Pen CreateDefaultLineBrush()
        {
            return new Pen(Brushes.Red, 1);
        }

    }
}
